<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="style.css" type="text/css">
<title>TÌM KIẾM SẢN PHẨM</title>
<?php
	//Ket noi CSDL
	$db = mysql_connect("localhost", "root", "");
	if(!$db)
	{
		echo "Khong the ket noi CSDL!!!";
		exit;
	}
	mysql_select_db("quangcaosp");
	mysql_query("SET character_set_results=utf8", $db);

?>
</head>
<body marginwidth="0" marginheight="0">
<table border="0" cellpadding="0" cellspacing="0" align="center" width="100%">
  <tr>
    <td width="100%" height="772"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="50%"><table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%">
              <tr>
                <td background="images/rez_top.jpg" style="background-repeat:repeat-x; width:50%; height:142px;"></td>
              </tr>
              <tr>
                <td background="images/rez_bgr.jpg" style="background-repeat:repeat; width:50%; height:100%;"></td>
              </tr>
              <tr>
                <td background="images/rez_bot.jpg" style="background-repeat:repeat-x; width:50%; height:87px;"></td>
              </tr>
            </table></td>
          <td width="766" bgcolor="#FFFFFF"><table border="0" cellpadding="0" cellspacing="0" width="766" height="100%">
              <!--flash-->
              <tr>
                <td width="766" height="142" background="images/rez_top.jpg" style="background-repeat:repeat-x; width:766px; height:142px;"><table border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td width="766" height="89"><table border="0" cellpadding="0" cellspacing="0">
                          <tr>
                            <td><a href="#"><img src="images/slogan.jpg" width="208" height="46" border="0" style="margin:28px 0 0 24px;"></a></td>
                            <td width="262"><p style="margin-top:47px;"><img src="images/txt_best.jpg"></p></td>
                            <td><img src="images/aa2.jpg" style="margin-right:9px;"></td>
                            <td width="159"><table border="0" cellpadding="0" cellspacing="0" style="margin-top:14px;">
                                <tr>
                                  <td><a href="#"><img src="images/b1.jpg" width="21" height="15" border="0"></a><a href="#"><img src="images/b2.jpg" width="21" height="15" border="0" style="margin:0 7px 0 4px;"></a></td>
                                  <td><select style="width:83px; height:17px; font-weight:900; font-size:10px;">
                                      <option>VN Dong</option>
                                    </select></td>
                                </tr>
                                <tr>
                                  <td><img src="images/spacer.gif" width="1" height="6"></td>
                                </tr>
                                <tr>
                                  <td colspan="10"><a href="#"><img src="images/x1.jpg" width="136" height="39" border="0"></a></td>
                                </tr>
                              </table></td>
                            <td><p align="center"><a href="index.php">
                                <input type="image" src="images/p1.jpg">
                                </a>
                                <input type="image" src="images/p2.jpg">
                                <a href="mailto:">
                                <input type="image" src="images/p3.jpg">
                                </a></p>
                              <p>&nbsp;</p>
                              <a title='Facebook quảng cáo sản phẩm' href='http://www.facebook.com/sanpham360.vn' target='_blank'><img alt='' src="images/imgFollowMeFacebook.png" class='img_absmiddle' width="90" height="15"/></a>
				<a title='Twitter quảng cáo sản phẩm' href='http://www.twitter.com/quangcaosanpham' target='_blank'><img alt='' src="images/imgFollowMeTwitter.png" class='img_absmiddle' width="90" height="15"/></a>
				<a title='Youtube quảng cáo sản phẩm' href='http://www.youtube.com/quangcaosanpham' target='_blank'><img alt='' src="images/imgFollowMeYouTube.png" class='img_absmiddle' width="90" height="15"/></a>
				<a title='Myspace quảng cáo sản phẩm' href='http://www.myspace.com/quangcaosanpham' target='_blank'><img alt='' src="images/imgFollowMeMySpace.png" class='img_absmiddle' width="90" height="15"/></a></td>
                          </tr>
                        </table></td>
                    </tr>
                    <tr>
                      <td height="53" width="766"><table border="0" cellpadding="0" cellspacing="0" width="766">
                          <tr>
                            <td><img src="images/spacer.gif" width="1" height="17"></td>
                            <td width="204"><table border="0" cellpadding="0" cellspacing="0" width="204">
                                 <tr>
                                  <td height="21" align="center" valign="middle"><a href="../dangnhap.php">
                                    <label>
                                    </label>
                                  </a>
                                    <label><center>
                                      <p>&nbsp;</p>
                                      <p align="center" class="style1"><a href="dangnhap.php">Đăng nhập</a>&nbsp; 
                                        <label class="style1"><a href="dangki.php">Đăng kí</a></label>
                                      </p>
                                      <p>&nbsp;</p>
                                  </label></td>
                                </tr>
                                <tr>
                                  <td width="204" height="32" bgcolor="#FFFFFF"><p style="margin:16px 0 0 15px; color:#696969;"><strong>Tìm kiếm trên web:</strong></p></td>
                                </tr>
                              </table></td>
                            <td><img src="images/aa11.jpg"></td>
                            <td width="492"><table border="0" cellpadding="0" cellspacing="0" width="492">
                                <tr>
                                  <td class="m1" onMouseOver="this.className='m1m'" onMouseOut="this.className='m1'"><a href="index.php"><img src="images/spacer.gif" width="52" height="53" border="0"></a></td>
                                  <td class="m2" onMouseOver="this.className='m2m'" onMouseOut="this.className='m2'"><a href="san_pham_hot.php"><img src="images/spacer.gif" width="121" height="53" border="0"></a></td>
                                  <td class="m3" onMouseOver="this.className='m3m'" onMouseOut="this.className='m3'"><a href="thong_tin_tai_khoan.php"><img src="images/spacer.gif" width="104" height="53" border="0"></a></td>
                                  <td class="m4" onMouseOver="this.className='m4m'" onMouseOut="this.className='m4'"><a href="gianhang.php"><img src="images/spacer.gif" width="122" height="53" border="0"></a></td>
                                  <td class="m5" onMouseOver="this.className='m5m'" onMouseOut="this.className='m5'"><a href="lienhe.php"><img src="images/spacer.gif" width="126" height="53" border="0"></a></td>
                                </tr>
                              </table></td>
                          </tr>
                        </table></td>
                    </tr>
                  </table></td>
              </tr>
              <!--footer-->
              <tr>
                <td height="529"><table border="0" cellpadding="0" cellspacing="0" height="100%">
                    <tr>
                      <td width="246"><table border="0" cellpadding="0" cellspacing="0" width="246" height="100%">
                          <tr>
                            <td width="231" height="58"><form action="" method="post">
                                <table border="0" cellpadding="0" cellspacing="0" style="margin-left:15px;">
                                  <tr>
                                    <td><input name="tim_kiem" type="text" id="tim_kiem" style="width:142px; height:19px; border:1px solid #767676;" value="<?php echo $_POST["tim_kiem"];?>"></td>
                                    <td><input type="image" src="images/kn_go.jpg" style="margin-left:2px;"></td>
                                  </tr>
                                  <tr>
                                    <td><img src="images/spacer.gif" width="1" height="5"></td>
                                  </tr>
                                  <tr>
                                    <td colspan="10"><a href="#" class="ins" style="color:#FF9536; font-size:10px;">consetetur</a></td>
                                  </tr>
                                </table>
                              </form></td>
                          </tr>
                          <tr>
                            <td width="246" height="100%"><table border="0" cellpadding="0" cellspacing="0" style="margin-left:15px;" width="216" height="100%">
                                <tr>
                                  <td><img src="images/txt_shop.jpg"></td>
                                </tr>
                                <tr>
                                  <td width="216" height="100%" bgcolor="#F6F6F6"><table border="0" cellpadding="0" cellspacing="0" style="margin:16px 0 0 20px;">
                                      <tr>
                                        <td><?php
									  $result = mysql_query("SELECT * FROM loaisp");	
										if(mysql_num_rows($result) <> 0)
										{
											  
											  while ($row = mysql_fetch_row($result))
											  {
												 
												$MaLoaiSP = $row[0];
												$TenLoaiSP = $row[1];
												  echo "<tr>";
													echo " <td><p><img src='images/ch_12.jpg' style='margin-right:17px;'><a href='#' class='deep' style='font-weight:900;'>$TenLoaiSP</a></p>";
                                       echo "<p style='margin:3px 0 3px 14px;'><img src='images/dot_left.jpg'></p>";
													
												  echo "</tr>";
												 
											  }
										
										}
									?>
                                          <p style="margin:3px 0 3px 14px;"><img src="images/dot_left.jpg"></p>
                                          <p style="margin:3px 0 3px 14px;"><img src="images/dot_left.jpg"></p></td>
                                      </tr>
                                    </table></td>
                                </tr>
                              </table></td>
                          </tr>
                          <tr>
                            <td><a href="#"><img src="images/x111.jpg" width="246" height="150" border="0"></a></td>
                          </tr>
                        </table></td>
                      <td><table border="0" cellpadding="0" cellspacing="0">
                          <td><?php
												$db = mysql_connect("localhost", "root", "");
												mysql_query("SET NAMES 'utf8'", $db);
			if(!$db)
			{
				echo "Không thể kết nối CSDL";
				exit;
			}
			mysql_select_db("quangcaosp");
			if(isset($_REQUEST["tim_kiem"]) && ($_REQUEST["tim_kiem"]!= ""))
			{
				$tukhoa_sp = $_REQUEST["tim_kiem"];
				$result = mysql_query("SELECT * FROM sanpham WHERE tukhoatimkiem like '%$tukhoa_sp%'");
				if(mysql_num_rows($result)<>0)
				{
					$n = mysql_num_rows($result);
					echo "<p align = 'center'><b>Có $n sản phẩm được tìm thấy!!!</b></p>";
					echo "<table align = 'center' width='450' >";
					$stt=0;
					
					while($row = mysql_fetch_row($result))
					{
						$masp = $row[0];
						$tensp = $row[1];
						$giaca = number_format($row[2], 0 , ".", ".");
						$loaihinh = $row[3];
						$noiban = $row[4];
						$hangsx = $row[5];
						$baohanh = $row[6];
						$motact = $row[9];
						$hinh = "hinh_san_pham/".$row[0].".jpg";
						$hinh = "<img src ='$hinh' alt = '$tensp'>";
						if($stt%2==0)
							{echo "<tr>";}
						
						
						echo "<td>";
							echo "<table width='225'>";
							echo "<tr><td align = 'center' colspan ='2' bgcolor= '#FFEEE6' class = 'style1'> $tensp <br><br> $giaca VNĐ</td></tr>";
							echo "<tr><td align = 'center'>$hinh</td></tr>";
							echo "<tr><td align = 'left'><i><b>Loại hình: </b></i> $loaihinh</td></tr>";
							echo "<tr><td align = 'left'><i><b>Nơi bán: </b></i> $noiban</td></tr>";
							echo "<tr><td align = 'left'><i><b>Hãng sản xuất: </b></i> $hangsx </td></tr>";
							echo "<tr><td align = 'left'><i><b>Bảo hành: </b></i> $baohanh</td></tr>";
							echo "<tr><td align = 'left'><i><b>Mô tả chi tiết: </b></i> $motact</td></tr>";
						echo "</table>";
						echo "</td>";
						$stt +=1;
						echo "</td>";
						if($stt%2==0)
							{echo "</tr>";}
					}
					echo "</table>";
				}
		
		else
		
			echo "<p align='center'><b>Không tìm thấy sản phẩm này!!!</b></p>";
		}
										?>
                            </td>
                        </table></td>
                    </tr>
                  </table></td>
              </tr>
              <!--end_line-->
              <tr>
                <td width="766"><table border="0" cellpadding="0" cellspacing="0" width="766">
                    <tr>
                      <td><img src="images/w1.jpg"></td>
                       <td background="images/w3_bgr.jpg" style="background-repeat:repeat-x; width:711px; height:101px;"><p style="margin:37px 0 0 131px; " class="end"><strong class="end" style="text-decoration:underline;"><a href="index.php">Home</a></strong> &nbsp; |&nbsp; <a href="san_pham_hot.php"> Sản phẩm hot</a> &nbsp; |&nbsp; <a href="quan_ly_san_pham.php">Quản lý sản phẩm </a> |&nbsp; <a href="quan_ly_gian_hang.php">Quản lý gian hàng </a> &nbsp;|&nbsp; <a href="lienhe.php">Liên hệ</a>|&nbsp; <a href="lienketvang.php">Liên kết vàng</a> |&nbsp; <a href="top_estore.php">Top Estore</a></p>
                        <p style="margin:35px 0 0 261px;" class="end1">Bản quyền thuộc về &copy; 2012.WeAreOne. All rights reserved</p></td>
                      <td><img src="images/w2.jpg"></td>
                    </tr>
                  </table></td>
              </tr>
            </table></td>
          <td width="50%"><table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%">
              <tr>
                <td background="images/rez_bgr.jpg" style="background-repeat:repeat; width:50%; height:100%;"></td>
              </tr>
              <tr>
                <td background="images/rez_bot.jpg" style="background-repeat:repeat-x; width:50%; height:87px;"></td>
              </tr>
            </table></td>
        </tr>
      </table></td>
  </tr>
</table>
</body>
</html>
